package CharacterTraits
{
	import CharacterTraits.PersonalityLevel;
	
	public class Personality 
	{
		private var Openness:Number;
		private var Conscientiousness:Number;
		private var Extraversion:Number;
		private var Agreeableness:Number;
		private var Neuroticism:Number;
		
		public function Personality(O:Number = .5, C:Number = .5, E:Number = .5, A:Number = .5, N:Number = .5) 
		{
			SetPersonality(O, C, E, A, N); 
		}
		
		public function SetPersonality(O:Number, C:Number, E:Number, A:Number, N:Number):void
		{
			SetOpenness(O);
			SetConscientiousness(C);
			SetExtraversion(E);
			SetAgreeableness(A);
			SetNeuroticism(N);
		}
		
		public function SetOpenness(value:Number):void
		{
			value = KeepInRange(value);
			Openness = value;
		}
		
		public function SetConscientiousness(value:Number):void
		{
			value = KeepInRange(value);
			Conscientiousness = value;
		}
		
		public function SetExtraversion(value:Number):void
		{
			value = KeepInRange(value);
			Extraversion = value;
		}
		
		public function SetAgreeableness(value:Number):void
		{
			value = KeepInRange(value);
			Agreeableness = value;
		}
		
		public function SetNeuroticism(value:Number):void
		{
			value = KeepInRange(value);
			Neuroticism = value;
		}
		
		public function GetOpennessLevel():uint
		{
			return PersonalityLevel.GetLevel(Openness);
		}
		
		public function GetConscientiousnessLevel():uint
		{
			return PersonalityLevel.GetLevel(Conscientiousness);
		}
		
		public function GetExtraversionLevel():uint
		{
			return PersonalityLevel.GetLevel(Extraversion);
		}
		
		public function GetAgreeablenessLevel():uint
		{
			return PersonalityLevel.GetLevel(Agreeableness);
		}
		
		public function GetNeuroticismLevel():uint
		{
			return PersonalityLevel.GetLevel(Neuroticism);
		}
		
		private function KeepInRange(value:Number):Number
		{
			if (value < 0.0)
			{
				return 0;
			}
			
			if (value > 1.0)
			{
				return 1;
			}
			
			return value;
		}
	}
}